//
//  LGHistoryPrescriptionController.m
//  BreathTrainingTool
//
//  Created by 1234 on 2025/1/3.
//  历史处方详情

#import "LGHistoryPrescriptionController.h"
#import "LGPrescriptionChartController.h"
@interface LGHistoryPrescriptionController ()
/**   */
@property (nonatomic , strong)NSMutableArray *controllerArray;
/**  吸气训练 */
@property (nonatomic , strong)LGPrescriptionChartController *inhaleVC;
/**  呼气训练 */
@property (nonatomic , strong)LGPrescriptionChartController *exhaleVC;
/**  排痰训练 */
@property (nonatomic , strong)LGPrescriptionChartController *excretionVC;
/**   */
@property (nonatomic , strong)NSArray *titleArray;

@end

@implementation LGHistoryPrescriptionController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"呼吸训练统计";
    self.titleArray = @[@"吸气训练",@"呼气训练",@"排痰训练"];
    [self addChildViewController:self.inhaleVC];
    [self addChildViewController:self.exhaleVC];
    [self addChildViewController:self.excretionVC];
    [self.controllerArray addObject:self.inhaleVC];
    [self.controllerArray addObject:self.exhaleVC];
    [self.controllerArray addObject:self.excretionVC];

    self.scrollView.backgroundColor = [UIColor clearColor];
    self.titleColorNormal = [UIColor colorWithString:@"#606266"];
    self.titleColorSelected = [UIColor colorWithString:kThemeColor];
    self.progressColor = [UIColor colorWithString:kThemeColor];
    self.menuView.backgroundColor = [UIColor clearColor];
    self.menuViewStyle=WMMenuViewStyleLine;
    self.titleFontName = @"STHeitiTC-Medium";
    self.titleSizeSelected = 16;
    self.titleSizeNormal = 14;
    self.progressWidth = viewPix(13);
    self.progressHeight = 3;
    self.progressViewBottomSpace = 0;
    self.progressViewCornerRadius = 2;
    self.selectIndex = 0;
    [self reloadData];
    self.scrollView.backgroundColor = [UIColor clearColor];
}

#pragma mark
#pragma mark ====> WMPageControllerDelegate
- (NSInteger)numbersOfChildControllersInPageController:(WMPageController *)pageController {
    return self.titleArray.count;
}

- (NSString *)pageController:(WMPageController *)pageController titleAtIndex:(NSInteger)index {
    return self.titleArray[index];
}

- (UIViewController *)pageController:(WMPageController *)pageController viewControllerAtIndex:(NSInteger)index {
    return self.controllerArray[index];
}

- (CGFloat)menuView:(WMMenuView *)menu widthForItemAtIndex:(NSInteger)index {
    return Screen_W/3.0;
}

- (CGRect)pageController:(WMPageController *)pageController preferredFrameForMenuView:(WMMenuView *)menuView {
    return CGRectMake(0, 0, Screen_W, viewPix(44));
}

- (CGRect)pageController:(WMPageController *)pageController preferredFrameForContentView:(WMScrollView *)contentView {
    return CGRectMake(0, viewPix(44), Screen_W, Screen_H-topBarHeight-viewPix(44));
}

- (void)pageController:(WMPageController *)pageController willEnterViewController:(__kindof UIViewController *)viewController withInfo:(NSDictionary *)info{
    NSInteger index = [info[@"index"] integerValue];
    
//    LGBaseViewController *controller = (LGBaseViewController *)viewController;
//    [controller requestData];
//    NSLog(@">>>>>willEnterView>>>%@",viewController.title);
}

- (void)pageController:(WMPageController *)pageController didEnterViewController:(__kindof UIViewController *)viewController withInfo:(NSDictionary *)info{
    NSLog(@">>>>>didEnterView>>>%@",viewController.title);
}


-(NSMutableArray *)controllerArray{
    if(!_controllerArray){
        _controllerArray = [NSMutableArray array];
    }
    return _controllerArray;
}

-(LGPrescriptionChartController *)inhaleVC{
    if(!_inhaleVC){
        _inhaleVC = [[LGPrescriptionChartController alloc]init];
        _inhaleVC.patientid = self.patientid;
        _inhaleVC.type = @"1";
    }
    return _inhaleVC;
}

-(LGPrescriptionChartController *)exhaleVC{
    if(!_exhaleVC){
        _exhaleVC = [[LGPrescriptionChartController alloc]init];
        _exhaleVC.patientid = self.patientid;
        _exhaleVC.type = @"0";
    }
    return _exhaleVC;
}

-(LGPrescriptionChartController *)excretionVC{
    if(!_excretionVC){
        _excretionVC = [[LGPrescriptionChartController alloc]init];
        _excretionVC.patientid = self.patientid;
        _excretionVC.type = @"2";
    }
    return _excretionVC;
}

@end
